<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@include file="/WEB-INF/jsp/common/head.jsp" %>
<div class="right">
    <div class="location">
        <strong>当前位置:</strong>
        <span>用户管理页面</span>
    </div>
    <div class="search">
        <form method="get" action="${pageContext.request.contextPath }/user/userListPage">
            <span>用户名：</span>
            <input name="userName" class="input-text" type="text" value="${userName }">

            <span>角色：</span>
            <select name="userRole">
                <c:if test="${roleList != null }">
                    <option value="0">--全部--</option>
                    <c:forEach var="role" items="${roleList}">
                        <option <c:if test="${role.id == userRole }">selected="selected"</c:if>
                                value="${role.id}">${role.roleName}</option>
                    </c:forEach>
                </c:if>
            </select>

            <input type="hidden" name="pageIndex" value="1"/>
            <input value="查 询" type="submit" id="searchbutton">
            <a href="${pageContext.request.contextPath}/user/toAdd">添加</a>
        </form>
    </div>
    <!--用户-->
    <table class="supplierTable" cellpadding="0" cellspacing="0">
        <tr class="firstTr">
            <th width="15%">账号</th>
            <th width="15%">真实姓名</th>
            <th width="10%">角色</th>
            <th width="10%">性别</th>
            <th width="10%">年龄</th>
            <th width="10%">电话</th>
            <th width="30%">操作</th>
        </tr>
        <c:forEach var="user" items="${page.list}" varStatus="status">
            <tr>
                <td>
                    <span>${user.userCode }</span>
                </td>
                <td>
                    <span>${user.userName }</span>
                </td>
                <td>
                        <%-- <span>${user.userRole}</span>--%>
                    <span>
                        <c:if test="${user.userRole==1}">系统管理员</c:if>
                        <c:if test="${user.userRole==2}">经理</c:if>
                        <c:if test="${user.userRole==3}">普通员工</c:if>
                    </span>

                </td>
                <td>
							<span>
								<c:if test="${user.gender==1}">女</c:if>
								<c:if test="${user.gender==2}">男</c:if>
							</span>
                </td>
                <td>
                    <span><fmt:formatDate value="${user.birthday}" pattern="yyyy-MM-dd"/></span>
                </td>
                <td>
                    <span>${user.phone}</span>
                </td>
                <td>
                    <span><a class="viewUser" href="javascript:;" userid=${user.id } account=${user.userCode }><img
                            src="${pageContext.request.contextPath }/statics/images/view.png" alt="查看" title="查看"/></a></span>
                    <span><a class="modifyUser" href="javascript:;" userid=${user.id } account=${user.userCode }><img
                            src="${pageContext.request.contextPath }/statics/images/upd.png" alt="修改"
                            title="修改"/></a></span>
                        <%--                    <span><a class="deleteUser" href="javascript:;" userid=${user.id } account=${user.userCode }><img
                                                    src="${pageContext.request.contextPath }/statics/images/del.png" alt="删除"
                                                    title="删除"/></a></span>--%>
                    <span><a class="" href="${pageContext.request.contextPath }/user/deleteById?id=${user.id}"><img
                            src="${pageContext.request.contextPath }/statics/images/del.png" alt="删除"
                            title="删除"/></a></span>
                </td>
            </tr>
        </c:forEach>
    </table>
    <%--隐藏一个总页数,将来在跳转页时js通过去该数据判断是否页面大小合法--%>
    <input type="hidden" id="totalPageCount" value="${page.totalPage}"/>
    <div class="page-bar">
        <ul class="page-num-ul clearfix">
            <li>共${page.totalRecord }条记录&nbsp;&nbsp; ${page.currentPage }/${page.totalPage }页</li>
            <c:if test="${page.currentPage > 1}">
                <%--document.forms[0]  获得当前页面的第一个表单--%>
                <a href="javascript:page_nav(document.forms[0],1);">首页</a>
                <a href="javascript:page_nav(document.forms[0],${page.currentPage-1});">上一页</a>
            </c:if>
            <c:if test="${page.currentPage < page.totalPage }">
                <a href="javascript:page_nav(document.forms[0],${page.currentPage+1 });">下一页</a>
                <a href="javascript:page_nav(document.forms[0],${page.totalPage });">尾页</a>
            </c:if>
            &nbsp;&nbsp;
        </ul>
        <span class="page-go-form"><label>跳转至</label>
	     <input type="text" name="inputPage" id="inputPage" class="page-key" />页
	     <button type="button" class="page-btn" onClick='jump_to(document.forms[0],document.getElementById("inputPage").value)'>GO</button>
		</span>
    </div>

    <div class="supplierAdd">
        <div>
            <label>用户编码：</label>
            <input type="text" id="v_userCode" value="" readonly="readonly">
        </div>
        <div>
            <label>用户名称：</label>
            <input type="text" id="v_userName" value="" readonly="readonly">
        </div>
        <div>
            <label>用户性别：</label>
            <input type="text" id="v_gender" value="" readonly="readonly">
        </div>
        <div>
            <label>出生日期：</label>
            <input type="text" Class="Wdate" id="v_birthday" value=""
                   readonly="readonly" onclick="WdatePicker();">
        </div>
        <div>
            <label>用户电话：</label>
            <input type="text" id="v_phone" value="" readonly="readonly">
        </div>
        <div>
            <label>用户角色：</label>
            <input type="text" id="v_userRoleName" value="" readonly="readonly">
        </div>
        <div>
            <label>用户地址：</label>
            <input type="text" id="v_address" value="" readonly="readonly">
        </div>
        <div>
            <label>图片：</label>
            <img src="" id="attach" height="" width="">
        </div>
    </div>
</div>
</section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeUse">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>确定删除该用户吗？</p>
            <a href="#" id="yes">是</a>
            <a href="#" id="no">否</a>
        </div>
    </div>
</div>

<%@include file="/WEB-INF/jsp/common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/sysUser/list.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/sysRole/rollpage.js"></script>
